import {
  Controller,
  Post,
  Body,
  Patch,
  Delete,
  Query,
  UseGuards,
} from '@nestjs/common';
import { UserService } from './user.service';
import { CreateUserDto } from './dto/create-user.dto';
import { UpdateUserDto } from './dto/update-user.dto';
import { UserPipe } from './user.pipe';
import { LoginGuard } from 'src/login.guard';

@Controller('user')
export class UserController {
  constructor(private readonly userService: UserService) {}

  @UseGuards(LoginGuard)
  @Post()
  create(@Body(UserPipe) createUserDto: CreateUserDto) {
    return this.userService.create(createUserDto);
  }

  @UseGuards(LoginGuard)
  @Post('getUserList')
  getUserList(@Body() query: any) {
    return this.userService.getUserList(query);
  }

  // @Get(':id')
  // findOne(@Param('id', ParseUUIDPipe) id: number) {
  //   return this.userService.findOne(+id);
  // }

  @Patch()
  update(@Query() query: any, @Body() updateUserDto: UpdateUserDto) {
    return this.userService.update(Number(query?.id), updateUserDto);
  }

  @Delete()
  remove(@Query() query: any) {
    return this.userService.remove(Number(query?.id));
  }
}
